import time
import gzip
import json
import multiprocessing as mp


def test(f):
    cnt = 0
    start = time.time()
    for _ in f:
        cnt += 1
    end = time.time()
    return end - start, cnt


def f():
    a = {"a": 123, "b": 54}
    b = {"a": 100, "v": 1230}
    return {"a": a, "b": b}


def dict_save(d: dict, pth):
    d_js = json.dumps(d, indent=4)
    with open(pth, "w", encoding="utf-8") as f:
        f.write(d_js)


def dict_load(pth):
    with open(pth, "r", encoding="utf-8") as f:
        d = json.load(f)
    return d


def judge(ent_info, d2f):
    a = set(d2f.values())
    b = set(ent_info.keys())
    return a - b


def run_commands(arg_list: list):
    print(arg_list)
    # subprocess.call(" ".join(arg_list), shell=True)


def run_baseline(p):
    base_command = "python main_KG_free.py --cuda --gpu_id 2 --print_every 30"
    embed_dim_list = [8, 16, 32, 64]
    lr_list = [0.1, 0.01, 0.001]
    p = mp.Pool(12)
    for dim in embed_dim_list:
        for lr in lr_list:
            arg_list = [base_command]
            arg_list.extend([f"--embed_dim {dim}", f"--lr {lr}"])
            run_commands(arg_list)
            p.apply(run_commands, (arg_list,))
    p.close()
    p.join()


def bre():
    for i in range(10):
        for j in range(15):
            print(i, j)


if __name__ == "__main__":
    # d2f = dict_load("./res/douban2fb.json")
    # ent_info = dict_load("./tmp/ent_info_0_before.json")
    # judge(ent_info, d2f)
    bre()
